PROCEDURE MyRequest(title,textFormat,gadgetFormat: ARRAY OF CHAR;
args: e.APTR): LONGINT; (* $CopyArrays- *)
VAR res: LONGINT;
BEGIN
BlockWindow;
res := rt.EZRequestTags(textFormat,gadgetFormat,NIL,args,rt.ezReqTitle,SYS.ADR(title),u.end);
UnBlockWindow;
RETURN res;
END MyRequest;
PROCEDURE Assert(cc: BOOLEAN; txt: ARRAY OF CHAR); (* $CopyArrays- *)
BEGIN
IF ~cc THEN
IF MyRequest("Information",txt,"Cancel",NIL)=0 THEN END;
HALT(d.fail);
END;
END Assert;
PROCEDURE RFProc; (* $EntryExitCode- *)
BEGIN
SYS.INLINE(016C0U,04E75U);
END RFProc;
PROCEDURE SplitLine(VAR line,first,rest: ARRAY OF CHAR);
VAR i,j,k,l: LONGINT;
quote,take,gotFirst: BOOLEAN;
ch,lastCh: CHAR;
BEGIN
quote := FALSE; gotFirst := FALSE;
i := 0; j := 0; k := 0; ch := 0X;
l := str.Length(line);
WHILE i<l DO
take := TRUE; lastCh := ch; ch := line[i];
CASE ch OF
| '"' : quote := ~quote; IF ~quote OR (lastCh#'"') THEN take := FALSE END;
| " ","\t" : IF ~quote & ~gotFirst THEN
gotFirst := TRUE;
WHILE (i<l-1) & ((line[i+1]=" ")OR(line[i+1]="\t")) DO INC(i) END;
take := FALSE;
END;
ELSE
END;
IF take THEN
IF ~gotFirst THEN
IF j<LEN(first) THEN first[j] := ch; INC(j) END;
ELSE
IF k<LEN(rest) THEN rest [k] := ch; INC(k) END;
END;
END;
INC(i);
END;
IF j<LEN(first) THEN first[j] := 0X END;
IF k<LEN(rest) THEN rest [k] := 0X END;
END SplitLine;
PROCEDURE LoadConfig;
VAR file: fs.File;
string,keyword,valueStr: e.STRING;
value,dummy,i: LONGINT;
BEGIN
config.device := "serial.device";
config.unit := 0;
config.initString := "ATZ\\r~~";
config.hangupString := "^~~~+++~~~ATH0\\r";
config.rBufLen := 8192;
config.baud := 2400;
config.breakTime := 250000;
config.bitsPerChar := 8;
config.stopBits := 1;
config.parity := none;
config.handShaking := ctsrts;
config.radBoogie := FALSE;
config.duplex := fullduplex;
config.keyMap := "";
config.font := "";
config.protocol := "";
config.downloadDir := "";
config.uploadDir := "";
config.pasteDir := "";
config.capture := "T:Capture_";
config.screenDepth := 2;
config.time4connect := 0;
config.pasteDelay := 10;
config.priority := 0;
IF args.config # NIL THEN
COPY(args.config^,string);
ELSE
string := "Termite.config";
IF ~fs.Exists(string) THEN
string := "PROGDIR:Termite.config";
IF resident OR ~fs.Exists(string) THEN
string := "ENV:Termite.config";
IF ~fs.Exists(string) THEN
string := "s:Termite.config";
IF ~fs.Exists(string) THEN
string := ""
END;
END;
END;
END;
END;
IF fs.Open(file,string,FALSE) THEN
WHILE fs.ReadString(file,string) DO
IF RemSpaces(string) THEN
SplitLine(string,keyword,valueStr);
str.Upper(keyword);
value := StringToInt(valueStr,10);
IF keyword = "DEVICE" THEN config.device := valueStr
ELSIF keyword = "UNIT" THEN config.unit := SHORT(value)
ELSIF keyword = "HANDSHAKING" THEN str.Upper(valueStr); IF valueStr="XONXOFF" THEN config.handShaking:=xonxoff ELSIF valueStr="7WIRE" THEN config.handShaking:=ctsrts ELSE config.handShaking:=none END;
ELSIF keyword = "BAUDRATE" THEN config.baud := value
ELSIF keyword = "BREAKTIME" THEN config.breakTime := value
ELSIF keyword = "SERIALBUFFER"THEN config.rBufLen := value DIV 512 * 512;
ELSIF keyword = "PARITY" THEN str.Upper(valueStr); IF valueStr="EVEN" THEN config.parity:=even ELSIF valueStr="ODD"THEN config.parity:=odd ELSIF valueStr="MARK" THEN config.parity:=mark
IF ~OpenTransferWindow("Auto Transfer") THEN RETURN 0 END;
END;
rp := transferWin.rPort;
g.SetAPen(transferWin.rPort,2);
mask := us.updatemask;
IF (XPR.protocol IN mask)&(us.protocol #NIL)THEN PutText(transferWin, 2+11,2,us.protocol^,50) END;
IF (XPR.filename IN mask)&(us.filename #NIL)THEN PutText(transferWin, 2+11,3,us.filename^,50) END;
IF (XPR.blockcheck IN mask)&(us.blockcheck #NIL)THEN PutText(transferWin, 2+16,12,us.blockcheck^,14) END;
IF (XPR.expecttime IN mask)&(us.expecttime #NIL)THEN PutText(transferWin,32+15,12,us.expecttime^,14) END;
IF (XPR.elapsedtime IN mask)&(us.elapsedtime#NIL)THEN PutText(transferWin,32+15,13,us.elapsedtime^,14)END;
IF (XPR.msg IN mask)&(us.msg #NIL)THEN PutText(transferWin, 2+11,5,us.msg^,50); END;
IF (XPR.errormsg IN mask)&(us.errormsg #NIL)THEN PutText(transferWin, 2+11,6,us.errormsg^,50); END;
IF (XPR.filesize IN mask)&(us.filesize #-1) THEN e.RawDoFmt("%ld",SYS.ADR(us.filesize),RFProc,SYS.ADR(txt)); PutText(transferWin, 2+16, 8,txt,14) END;
IF (XPR.blocks IN mask)&(us.blocks #-1) THEN e.RawDoFmt("%ld",SYS.ADR(us.blocks),RFProc,SYS.ADR(txt)); PutText(transferWin, 2+16,10,txt,14) END;
IF (XPR.blocksize IN mask)&(us.blocksize #-1) THEN e.RawDoFmt("%ld",SYS.ADR(us.blocksize),RFProc,SYS.ADR(txt)); PutText(transferWin, 2+16,11,txt,14) END;
IF (XPR.bytes IN mask)&(us.bytes #-1) THEN e.RawDoFmt("%ld",SYS.ADR(us.bytes),RFProc,SYS.ADR(txt)); PutText(transferWin, 2+16, 9,txt,14) END;
IF (XPR.errors IN mask)&(us.errors #-1) THEN e.RawDoFmt("%ld",SYS.ADR(us.errors),RFProc,SYS.ADR(txt)); PutText(transferWin,32+15, 9,txt,14) END;
IF (XPR.timeouts IN mask)&(us.timeouts #-1) THEN e.RawDoFmt("%ld",SYS.ADR(us.timeouts),RFProc,SYS.ADR(txt)); PutText(transferWin,32+15, 8,txt,14) END;
IF (XPR.packetdelay IN mask)&(us.packetdelay#-1) THEN e.RawDoFmt("%ld",SYS.ADR(us.packetdelay),RFProc,SYS.ADR(txt)); PutText(transferWin,32+15,11,txt,14) END;
IF (XPR.chardelay IN mask)&(us.chardelay #-1) THEN e.RawDoFmt("%ld",SYS.ADR(us.chardelay),RFProc,SYS.ADR(txt)); PutText(transferWin,32+15,10,txt,14) END;
IF (XPR.datarate IN mask)&(us.datarate #-1) THEN e.RawDoFmt("%ld",SYS.ADR(us.datarate),RFProc,SYS.ADR(txt)); PutText(transferWin, 2+16,13,txt,14) END;
IF (XPR.bytes IN mask)&(us.bytes#-1) & (us.filesize>0) & (us.bytes<20000000) THEN